package com.example.base.net

import androidx.media3.datasource.DataSpec.HttpMethod
import com.example.base.entity.*
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.HTTP
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {

    @POST("/api/user/login")
    suspend fun login(
        @Query("username") username: String,
        @Query("password") password: String
    ): Res<UserBean>

    @POST("/api/user/register")
    suspend fun register(
        @Query("username") username: String,
        @Query("password") password: String
    ): Res<UserBean>


    //园区公告
    @GET("/api/announcements")
    suspend fun getAnnouncements(
        @Query("page") page: Int,
        @Query("size") size: Int
    ): Res<AnnouncementsBean>


    //车位
    @GET("/api/parking-spaces/type/{spaceType}")
    suspend fun getParkByType(@Path("spaceType") spaceType: String): Res<ParkBean>

    @GET("/api/parking-spaces/status/{spaceStatus}")
    suspend fun getParksByStatus(@Path("spaceStatus") spaceStatus: String): Res<ParkBean>

    @GET("/api/parking-spaces/area/{areaId}")
    suspend fun getParksByAreaId(@Path("areaId") areaId: Int): Res<ParkBean>
    //添加车位
    @POST("/api/parking-spaces")
    suspend fun addPark(@Body branItem: ParamPark): Res<ParkBeanItem>
    //修改车位
    @PUT("/api/parking-spaces/{id}")
    suspend fun editPark(@Path("id")id:Int,@Body body:RequestBody):Res<ParkBeanItem>
    //删除车位
    @HTTP(method = "DELETE", path = "/api/parking-spaces/{id}", hasBody = false)
    suspend fun deletePark(@Path("id")id:Int):Res<Boolean>


    //维修
    @GET("/api/repair-orders")
    suspend fun getRepairs():Res<RepairBean>
    //根据报修人查询报修工单
    @GET("/api/repair-orders/search")
    suspend fun getRepairsByUname(@Query("repairName")repairName:String):Res<RepairBean>
    //根据工单号获取报修工单
    @GET("/api/repair-orders/order-number/{orderNumber}")
    suspend fun getRepairsByNO(@Path("orderNumber")orderNumber:String):Res<RepairBeanItem>
    //根据 ID 获取报修工单详情
    @GET("/api/repair-orders/{id}")
    suspend fun getRepairById(@Path("id")id:Int):Res<RepairBeanItem>
    //更新报修工单
    @PUT("/api/repair-orders/{id}")
    suspend fun updateRepair(@Path("id")id:Int,@Body body:RequestBody):Res<RepairBeanItem>
    //添加维修单
    @POST("/api/repair-orders")
    suspend fun addRepairs(@Body body: RequestBody):Res<RepairBeanItem>
    //删除报修工单
    @DELETE("/api/repair-orders/{id}")
    suspend fun deleteRepair(@Path("id")id:Int):Res<Boolean>


    //获取所有预约来访
    @GET("/api/visit-appointments")
    suspend fun getVisit(): Res<VisitBean>
    //根据来访状态获取列表
    @GET("/api/visit-appointments/status/{status}")
    suspend fun getVisitByStatus(@Path("status")status:String):Res<VisitBean>
    //根据 ID 获取预约来访详情
    @GET("/api/visit-appointments/{id}")
    suspend fun getVisitById(@Path("id")id:Int):Res<VisitBeanItem>
    //审核预约来访
    @PATCH("/api/visit-appointments/approve/{id}")
    suspend fun approveVisit(@Path("id")id:Int):Res<VisitBeanItem>
    //驳回预约来访
    @PATCH("/api/visit-appointments/reject/{id}")
    suspend fun rejectVisit(@Path("id")id:Int):Res<VisitBeanItem>
    //删除预约来访
    @DELETE("/api/visit-appointments/{id}")
    suspend fun deleteVisit(@Path("id")id:Int):Res<Boolean>
    //创建预约来访
    @POST("/api/visit-appointments")
    suspend fun addVisit(@Body body: RequestBody):Res<VisitBeanItem>


    //考勤
    @GET("/api/attendances/user/{userId}")
    suspend fun getSigns(@Path("userId")userId:Int):Res<SignBean>
    //考勤打卡
    @POST("/api/attendances")
    suspend fun sign(@Body body: RequestBody):Res<SignBeanItem>

    //人员
    @GET("/api/employees")
    suspend fun getEmps():Res<EmpBean>
    //获取部门信息
    @GET("/api/departments")
    suspend fun getDeparts():Res<DepartBean>
    //创建员工
    @POST("/api/employees")
    suspend fun addEmp(@Body body: RequestBody):Res<EmpBeanItem>


    //房源
    @GET("/api/properties")
    suspend fun getHouse():Res<HouseBean>
    //根据区域 ID 查询房源列表
    @GET("/api/properties/region/{regionId}")
    suspend fun getHouseByRid(@Path("regionId")regionId:Int):Res<HouseBean>
    //出租房源
    @PATCH("/api/properties/rent/{id}")
    suspend fun rent(@Path("id")id: Int,@Query("rentDate")rentDate:String):Res<HouseBeanItem>
    //退租房源
    @PATCH("/api/properties/unrent/{id}")
    suspend fun unRent(@Path("id")id:Int):Res<HouseBeanItem>


    //商家入驻
    @GET("/api/merchant-applications")
    suspend fun getMerchant():Res<MerchantBean>
    //根据 ID 获取详情
    @GET("/api/merchant-applications/{id}")
    suspend fun getMerchantById(@Path("id")id:Int):Res<MerchantBeanItem>
    //审核商家入驻申请
    @PATCH("/api/merchant-applications/approve/{id}")
    suspend fun approve(@Path("id")id:Int):Res<MerchantBeanItem>
    //驳回商家入驻申请
    @PATCH("/api/merchant-applications/reject/{id}")
    suspend fun reject(@Path("id")id:Int):Res<MerchantBeanItem>
    //创建商家入驻申请
    @POST("/api/merchant-applications")
    suspend fun addMerchant(@Body body: RequestBody):Res<MerchantBeanItem>


    //获取所有巡检点位
    @GET("/api/patrol-points")
    suspend fun getPoints():Res<PointBean>
    //根据点位名称及位置获取巡检点位详情
    @GET("/api/patrol-points/search")
    suspend fun getPointsByType(@Query("location")location:String,@Query("name")name:String):Res<PointBean>
    //根据id获取巡检点位详情
    @GET("/api/patrol-points/{id}")
    suspend fun getPointById(@Path("id")id:Int):Res<PointBeanItem>
    //获取所有巡检任务
    @GET("/api/patrol-tasks")
    suspend fun getPatrolTasks():Res<PatrolTaskBean>
    //根据巡检状态获取巡检任务
    @GET("/api/patrol-tasks/by-status/{status}")
    suspend fun getPatrolTaskByStatus(@Path("status")status:String):Res<PatrolTaskBean>
    //根据id获取巡检任务详情
    @GET("/api/patrol-tasks/{id}")
    suspend fun getPatrolTasksById(@Path("id")id:Int):Res<PatrolTaskBeanItem>


    //添加收费项目
    @POST("/api/charge-items")
    suspend fun addPayProject(@Body body: RequestBody):Res<PayBeanItem>
    //根据缴费人 ID 获取所有收费项目
    @GET("/api/charge-items/payer/{payerId}")
    suspend fun getPayProjectsByUid(@Path("payerId")payerId:Int):Res<PayBean>






    //获取所有设备信息
    @GET("/api/devices")
    suspend fun getDevices():Res<DevicesBean>

}